package formBean;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class PasswordForm extends FormBean {

	private String userId;
	
	private String userName;
	
	private String oldPassword;
	
	private String newPassword;
	
	private String confirmPassword;

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = trimAndConvert(userId,"<>\"");;
	}

	public String getOldPassword() {
		return oldPassword;
	}

	public void setOldPassword(String oldPassword) {
		this.oldPassword = oldPassword;
	}

	public String getNewPassword() {
		return newPassword;
	}

	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = trimAndConvert(userName,"<>\"");;
	}

	public List<String> getValidationErrors() {
        List<String> errors = new ArrayList<String>();
        if(newPassword!= null && !newPassword.equals(confirmPassword))
        {
        	errors.add("New password not consistant");
        }
        
        if (oldPassword == null || oldPassword.length() == 0) errors.add("Old password is required");
        if (newPassword == null || newPassword.length() == 0) errors.add("New password is required");
        if (confirmPassword == null || confirmPassword.length() == 0) errors.add("Confirm of new password is required");
		
        return errors;
	}
	
	public List<String> getValidationErrorsForCustomerChange()
	{
		List<String> errors = new ArrayList<String>();
        if(newPassword!= null && !newPassword.equals(confirmPassword))
        {
        	errors.add("New password not consistant");
        }
        if (newPassword == null || newPassword.length() == 0) errors.add("New password is required");
        if (confirmPassword == null || confirmPassword.length() == 0) errors.add("Confirm of new password is required");
		
		if(userName == null || userName.length() ==0) errors.add("Customer Name is required");
		return errors;
	}
}
